//
//  HROrdeDetailFoot.m
//  haierapp
//
//  Created by Xia Zhiyong on 14-8-28.
//  Copyright (c) 2014年 haier. All rights reserved.
//

#import "HROrdeDetailFoot.h"

#define HEIGHT_SPERATE_VIEW 10.0f
#define HEIGHT_BUTTON_VIEW 40.0f

#define WEIGHT_TO_RIGHT 90.f
#define PADDING_RIGHT 10.f

@implementation HROrdeDetailFoot

-(id)initWithFrame:(CGRect)frame orderType:(int)orderType{
    self = (HROrdeDetailFoot *)[[[NSBundle mainBundle] loadNibNamed:@"HROrdeDetailFoot"
                                                                          owner:self
                                                                        options:nil] objectAtIndex:0];
    [self setFrame:frame];
//    [self hideAllViewInSubviews];
    [self showViewsWithType:orderType];
    return self;

}


-(void)hideAllViewInSubviews{
    _btnAgain.hidden = YES;
    _btnReturn.hidden = YES;
    _btnSure.hidden = YES;
    _btnPay.hidden = YES;
    _btnCancel.hidden = YES;
    _lblPrice.hidden = YES;
    
}

-(void)showViewsWithType:(int)type{
    [self hideAllViewInSubviews];
    switch (type) {
        case ORDER_TYPE_WAIT_FOR_PAY:
            //待付款[取消订单、付款]
            self.btnPay.hidden=NO;
            self.payTrailingSpace.constant=PADDING_RIGHT;
            self.payBtnWidth.constant = 70;
            
            self.btnCancel.hidden=NO;
            self.cancelTrailingSpace.constant=WEIGHT_TO_RIGHT;
            
            self.lblPrice.hidden = NO;
            self.lblTrailingSpace.constant = WEIGHT_TO_RIGHT*2;
            break;
        case ORDER_TYPE_WAIT_FOR_DELIVERY:
            //待发货[取消订单]
            self.btnCancel.hidden=NO;
            self.cancelTrailingSpace.constant=PADDING_RIGHT;
            break;
        case ORDER_TYPE_WAIT_FOR_RECEIPT:
            //待收货[取消订单、确认收货]
            self.btnSure.hidden=NO;
            self.sureTrailingSpace.constant=PADDING_RIGHT;
            
            self.btnCancel.hidden=NO;
            self.cancelTrailingSpace.constant=WEIGHT_TO_RIGHT;
            break;
         case ORDER_TYPE_RECEIPTED:
            //已收货［再次购买］
            self.btnAgain.hidden = NO;
            self.againTrailingSpace.constant = PADDING_RIGHT;
            break;
        case ORDER_TYPE_SUCCEED:
            //交易成功[查看进度、再次购买]
            self.btnAgain.hidden=NO;
            self.againTrailingSpace.constant=PADDING_RIGHT;
            break;
            
        case ORDER_TYPE_CLOSED:
            //交易关闭[查看进度]
            self.btnAgain.hidden=NO;
            self.againTrailingSpace.constant=PADDING_RIGHT;
            break;
        case ORDER_TYPE_AFTERSALE_DEALING:
            //售后处理
            break;
            
        case ORDER_TYPE_WAIT_COMMENT:
            //待评价
            break;
        default:
            break;
    }
}

-(void)showOrderAmount:(NSString *)orderAmount{
    _lblPrice.text = [NSString stringWithFormat:@"<font size=12 color='#ff8730'>合计</font><font size=15 color='#ff8730'> ¥%@ </font>",orderAmount];
}

- (IBAction)actionPay:(id)sender{
    if ([self.delegate respondsToSelector:@selector(paymentOrder)]) {
        [self.delegate paymentOrder];
    }
}
- (IBAction)actionCancle:(id)sender{
    if ([self.delegate respondsToSelector:@selector(cancelOrder)]) {
        [self.delegate cancelOrder];
    }
}
- (IBAction)actionTake:(id)sender{
    if ([self.delegate respondsToSelector:@selector(receiveProducts)]) {
        [self.delegate receiveProducts];
    }
}
- (IBAction)actionBuyAgain:(id)sender{
    if ([self.delegate respondsToSelector:@selector(buyAgainOrderProduct)]) {
        [self.delegate buyAgainOrderProduct];
    }
}
- (IBAction)returnGoods:(id)sender{
    if ([self.delegate respondsToSelector:@selector(returnsOrderProduct)]) {
        [self.delegate returnsOrderProduct];
    }
}

@end
